/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.pojo;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;

import models.util.MySqlDataAccessHelper;

/**
 *
 * @author KimLien
 */

public class StIevoucher {
    private static final long serialVersionUID = 1L;
   
    private boolean select;
    private String voucherID;
    
    private Date createdDate;
    private String cerateDate1;
    
    private String cusManID;
    private AcCustomer cusManInfo;
    
    private int iDDepartment;
    private Department depInfo;
    
    private String iDEmployee;
    private Employee empInfo;
    
    private String shipper;
    
    private String consignee;
    
    private String note;
   
    private String objectUsing;
    
    private String tradingPlace;
    
    private String constractID;
    private String parseDay;
    

    public String getParseDay() {
		return parseDay;
	}

	public void setParseDay(String parseDay) {
		this.parseDay = parseDay;
	}

	private ArrayList<StIevoucherdetail> listDetails;

    private int transactionTypeID;
    
    private int status=0;

    
    
    
    public boolean isSelect() {
		return select;
	}

	public void setSelect(boolean select) {
		this.select = select;
	}

	public int getiDDepartment() {
		return iDDepartment;
	}

	public void setiDDepartment(int iDDepartment) {
		this.iDDepartment = iDDepartment;
	}

	public String getiDEmployee() {
		return iDEmployee;
	}

	public void setiDEmployee(String iDEmployee) {
		this.iDEmployee = iDEmployee;
	}

	public ArrayList<StIevoucherdetail> getListDetails() {
		return listDetails;
	}

	public void setListDetails(ArrayList<StIevoucherdetail> listDetails) {
		this.listDetails = listDetails;
	}

	public StIevoucher() {
    }

    public StIevoucher(String voucherID) {
        this.voucherID = voucherID;
    }
//
//    public StIevoucher(Boolean select,String voucherID, Date createdDate, String cusManID, int iDDepartment, String iDEmployee, String constractID) {
//    	this.select=select;
//        this.voucherID = voucherID;
//        this.createdDate = createdDate;
//        this.cusManID = cusManID;
//        this.iDDepartment = iDDepartment;
//        this.iDEmployee = iDEmployee;
//        this.constractID = constractID;
//    }
//    private Format format1=new SimpleDateFormat("yyyy-MM-dd");
//    String stri=format1.format(obj)
    public StIevoucher(Boolean select,String voucherID, String createdDate, String cusManID, int iDDepartment, String iDEmployee, String constractID,String note) {
    	setParseDay(createdDate);
    	this.select=select;
        this.voucherID = voucherID;
        this.parseDay = createdDate;
        this.cusManID = cusManID;
        this.iDDepartment = iDDepartment;
        this.iDEmployee = iDEmployee;
        this.constractID = constractID;
        this.note=note;
    }
    public StIevoucher(String voucherID, Date createdDate, String cusManID, int iDDepartment, String iDEmployee, String constractID) {
        this.voucherID = voucherID;
        this.createdDate = createdDate;
        this.cusManID = cusManID;
        this.iDDepartment = iDDepartment;
        this.iDEmployee = iDEmployee;
        this.constractID = constractID;
    }

    public String getVoucherID() {
        return voucherID;
    }

    public void setVoucherID(String voucherID) {
        this.voucherID = voucherID;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    
        
    
	public String getCusManID() {
    	
        return cusManID;
    }

    public void setCusManID(String cusManID) {
        this.cusManID = cusManID;
    }

    public int getIDDepartment() {
        return iDDepartment;
    }

    public void setIDDepartment(int iDDepartment) {
        this.iDDepartment = iDDepartment;
    }

    public String getIDEmployee() {
        return iDEmployee;
    }

    public void setIDEmployee(String iDEmployee) {
        this.iDEmployee = iDEmployee;
    }

    public String getShipper() {
        return shipper;
    }

    public void setShipper(String shipper) {
        this.shipper = shipper;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getObjectUsing() {
        return objectUsing;
    }

    public void setObjectUsing(String objectUsing) {
        this.objectUsing = objectUsing;
    }

    public String getTradingPlace() {
        return tradingPlace;
    }

    public void setTradingPlace(String tradingPlace) {
        this.tradingPlace = tradingPlace;
    }

    public String getConstractID() {
        return constractID;
    }

    public void setConstractID(String constractID) {
        this.constractID = constractID;
    }

	public AcCustomer getCusManInfo() {
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		
		try {
			mysql.open();
			String sql = "select * from ac_customer where CustomerID='"+this.cusManID+"'";
			ResultSet rs = mysql.executeQuery(sql);
			while (rs.next()) {
				cusManInfo = new AcCustomer();
				cusManInfo.setCustomerId(rs.getString("CustomerID"));
				cusManInfo.setCustomerName(rs.getString("CustomerName"));
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			mysql.close();
		}
		return cusManInfo;
	}

	public void setCusManInfo(AcCustomer cusManInfo) {
		this.cusManInfo = cusManInfo;
	}

	public Department getDepInfo(String lang) {
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		
		try {
			mysql.open();
			String sql = "select * from department,department_lang " +
					"where department.IDDepartment=department_lang.IDDepartment " +
					"and department_lang.LangID='"+lang+"' " +
							"and department.IDDepartment="+this.iDDepartment;
			ResultSet rs = mysql.executeQuery(sql);
			while (rs.next()) {
				depInfo = new Department();
				depInfo.setIddepartment(rs.getInt("IDDepartment"));
				depInfo.setDepartmentName(rs.getString("DepartmentName"));
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			mysql.close();
		}
		return depInfo;
	}

	public void setDepInfo(Department depInfo) {
		this.depInfo = depInfo;
	}

	public Employee getEmpInfo() {
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		
		try {
			mysql.open();
			String sql = "select * from employee where IDEmployee='"+this.iDEmployee+"'";
			ResultSet rs = mysql.executeQuery(sql);
			while (rs.next()) {
				empInfo = new Employee();
				empInfo.setIdemployee(rs.getString("IDEmployee"));
				empInfo.setFullName(rs.getString("FullName"));
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			mysql.close();
		}
		return empInfo;
	}

	public void setEmpInfo(Employee empInfo) {
		this.empInfo = empInfo;
	}

	public int getTransactionTypeID() {
		return transactionTypeID;
	}

	public void setTransactionTypeID(int transactionTypeID) {
		this.transactionTypeID = transactionTypeID;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getCerateDate1() {
		return cerateDate1;
	}

	public void setCerateDate1(String cerateDate1) {
		this.cerateDate1 = cerateDate1;
	}

   
}
